#ifndef __EDGE_H__
#define __EDGE_H__

class Edge {
	public:
		// Para el caso de que 2 aristas solo
		// se distingan por su islope y esta sea 0(+0,-0).
		unsigned int num;
		int ymax;
		int ymin;
		int xmin;
		float x;
		float islope;

		Edge(int x1,int y1,int x2,int y2,unsigned int num){
			if(y1>y2){
				this->ymin = y2;
				this->ymax = y1;
				this->xmin = x2;
			}else{
				this->ymax = y2;
				this->xmin = x1;
				this->ymin = y1;
			}
			this->islope = (float)(x2-x1)/(float)(y2-y1);
			this->x    = (float)this->xmin;
			this->num = num;
		}

		~Edge(){}

		void stepX(){
			this->x += (this->islope);
		}

		int getX()const{
			return (int)floor(this->x+0.5f);
		}

		bool operator <(const Edge& edge){
			return this->x<edge.x;
		}
};

class EdgeYCompare{
	public:
		bool operator()(const Edge& e1,const Edge& e2){
			if(e1.ymin<e2.ymin){
				return true;
			}else if (e1.ymin==e2.ymin){
				if(e1.xmin<e2.xmin){
					return true;
				}else if(e1.xmin==e2.xmin){
					if(e1.islope<e2.islope)
						return true;
					else if(e1.islope==e2.islope)
						return e1.num<e2.num;
				}
			}

			return false;
		}
};

#endif //__EDGE_H__
